package com.ny.controller;

import com.ny.entity.DeviceMongo;
import com.ny.entity.Result;
import com.ny.service.DeviceMongoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/mongo/device")
public class DeviceMongoController {
    
    @Autowired
    private DeviceMongoService deviceMongoService;
    
    /**
     * 查询所有设备信息
     * URL: GET /mongo/device/findAll
     */
    @GetMapping("/findAll")
    public Result findAllDevices() {
        List<DeviceMongo> devices = deviceMongoService.findAllDevices();
        return Result.success(devices);
    }
    
    /**
     * 根据设备名称查询设备信息
     * URL: GET /mongo/device/findByName?deviceName=xxx
     */
    @GetMapping("/findByName")
    public Result findDevicesByName(@RequestParam String deviceName) {
        List<DeviceMongo> devices = deviceMongoService.findDevicesByName(deviceName);
        return Result.success(devices);
    }
}